package HLLib.userControl.HLPanelPickUp;

import javax.microedition.lcdui.Image;

import HLLib.base.HLGraphics;
import HLLib.base.HLGraphics_H;
import HLLib.base.HLImage;
import HLLib.base.HLScreen;
import HLLib.base.HLString;
import HLLib.control.HLPanel;
import HLLib.userControl.defalut.HLAdressListItem;

public class HLAddressListPanel extends HLPanel {

    public static final int TEXT_Y = 2;

    public static final int TEXT_X = 2;

    public int selectColor = 0xffff00;

    public int color = 0xffecf3fd;

    Image img;

    HLAdressListItem item;

    public HLAddressListPanel(HLAdressListItem item, Image img) {
        this.img = img;
        tabelStop = true;
        this.item = item;
        width = HLScreen.width;
        height = TEXT_Y + HLGraphics.StringHeight() * 2 + TEXT_Y;
    }

    public void AdjustSize() {
        if (parent != null) {
            parent.AdjustSize();
        }
    }

    public void Logic() {

        super.Logic();
        if (IsFocus()) {
            RefreshEvent(GetScreenX(), GetScreenY(), GAME_BUTTON_ACTION);
        }
    }

    public void Refresh() {
        super.Refresh();

    }

    public void Render(HLGraphics g) {
        // super.Render(g);
        int screenX = GetScreenX();
        int screenY = GetScreenY();
        g.FillRect(screenX, screenY, width, height, 0xffffffff);
        if (IsFocus()) {
            g.FillRect(screenX, screenY, width, height, HLPanelGroup.SELECTED_COLOR);// d0d9f2);//0xd0ebf2);
            g.DrawImage(new HLImage(img), screenX + width - img.getWidth() - 5, screenY + (height - img.getHeight() >> 1), HLGraphics_H.TRANS_NONE);
        } else {

        }
        int offsetX = screenX + TEXT_X;
        int offsetY = screenY + TEXT_Y;

        HLString name = new HLString(item.GetName());
        g.DrawString(name, offsetX, offsetY, 0xff0000ff, 0, TEXT_STYLE_NORMAL);

        offsetY += HLGraphics.StringHeight();
        String tels = "";
        if (item.tel.Count() > 0) {
            tels = (" " + (String) item.tel.items[0]);
        }
        g.DrawString(new HLString(tels), offsetX, offsetY, 0xff000000, 0, TEXT_STYLE_NORMAL);

    }

}
